/**	
 * タイトル：	日志操作类
 * 説明：    	
 *			
 * 会社名：	紹興日創軟件有限公司
 * 変更履歴：	2014/08/12 NIS 何
 *			新規作成
 *
 */
package com.nissoft.framework.util;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author NIS 何
 * @version 1.0
 */
public class LogUtil {

	public static void debug(Object message) {
		getLogger(getClassName()).debug(message);
	}

	public static void debug(Object message, Throwable e) {
		getLogger(getClassName()).debug(message, e);
	}

	public static void info(Object message) {
		getLogger(getClassName()).info(message);
	}

	public static void info(Object message, Throwable e) {
		getLogger(getClassName()).info(message, e);
	}

	public static void warn(Object message) {
		getLogger(getClassName()).warn(message);
	}

	public static void warn(Object message, Throwable e) {
		getLogger(getClassName()).warn(message, e);
	}

	public static void error(Object message) {
		getLogger(getClassName()).error(message);
	}

	public static void error(Object message, Throwable e) {
		getLogger(getClassName()).error(message, e);
	}

	public static Log getLogger(String name) {
		return LogFactory.getLog(name);
	}

	/**
	 * 获取调用者的类名
	 * 
	 */
	private static String getClassName() {
		StackTraceElement[] stacks = Thread.currentThread().getStackTrace();
		int index = 0;
		if (stacks.length >= 3) {
			index = 3;
		}
		return stacks[index].getClassName();
	}
}
